<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2015/9/2 0002
  Time: 下午 4:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE HTML>

<html>
<head>
    <title>修改密码</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script type="text/javascript" src="/static/bui/js/jquery-1.8.1.min.js"></script>
    <script type="text/javascript" src="/static/bui/js/bui.js"></script>
    <script type="text/javascript" src="/static/bui/js/config.js"></script>
    <%--<link href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">--%>
    <link href="/static/bui/css/bs3/dpl.css" rel="stylesheet" type="text/css"/>
    <link href="/static/bui/css/bs3/bui.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="demo-content">
    <div class="panel">
        <div class="panel-header">
            <h3>修改密码</h3>
        </div>
        <div class="panel-body">
            <form id="J_Form" method="post" action="" class="form-horizontal">
                <div class="row" style="margin-left: 300px;margin-top: 30px">
                    <div class="control-group span8">
                        <label class="control-label">原密码：</label>

                        <div class="controls">
                            <input type="password" name="lastPwd" data-rules="{required:true}"
                                   data-messages="{required:'原密码不能为空'}" class="input-normal control-text"
                                   data-tip="{text:'请输入原密码'}">
                        </div>
                    </div>
                </div>
                <div class="row" style="margin-left: 300px;margin-top: 30px">
                    <div class="control-group span8">
                        <label class="control-label">新密码：</label>

                        <div class="controls">
                            <input type="password" id="newPwd" name="newPwd" data-rules="{required:true}"
                                   data-messages="{required:'新密码不能为空'}" class="input-normal control-text"
                                   data-tip="{text:'请输入新密码'}">
                        </div>
                    </div>
                </div>
                <div class="row" style="margin-left: 300px;margin-top: 30px">
                    <div class="control-group span8">
                        <label class="control-label">再次输入新密码：</label>

                        <div class="controls">
                            <input type="password" name="newPwdAgain" data-rules="{equalTo:'#newPwd'}"
                                   class="input-normal control-text" data-tip="{text:'请再次输入新密码'}">
                        </div>
                    </div>
                </div>
                <div class="row form-actions actions-bar">
                    <div class="span13 offset3 " style="margin-left: 500px">
                        <button type="button" class="button button-primary" onclick="update();">保存</button>
                        <button type="reset" class="button">重置</button>
                    </div>
                </div>
            </form>
        </div>
        <!-- script start -->
        <script type="text/javascript" src="/static/js/jquery.min.js"></script>
        <script type="text/javascript" src="/static/bui/js/bui.js"></script>
        <script type="text/javascript" src="/static/bui/js/config.js"></script>
        <script type="text/javascript" src="/static/js/cxdate.js"></script>
        <script type="text/javascript">
            BUI.use('bui/form', function (Form) {
                new Form.HForm({
                    srcNode: '#J_Form',
                    defaultChildCfg: {
                        validEvent: 'blur' //移除时进行验证
                    }
                }).render();
            });
        </script>
        <script type="text/javascript">
            function update() {
                $.ajax({
                    type: 'post',
                    url: '/login/updatePwd',
                    data: $("#J_Form").serialize(),
                    success: function (data) {
                        if (data == 'success') {
                            msg = '修改密码成功！';
                            BUI.Message.Alert(msg, function () {
                                window.location.href = '/jsp/login.jsp'
                            }, 'success')
                        } else {
                            msg = '原密码错误！';
                            BUI.Message.Alert(msg, function () {
                                window.location.href = '/jsp/user/updatePwd.jsp';
                            }, 'error')
                        }
                    }
                })
            }
        </script>
    </div>
</div>
</body>
</html>
